<?php
header("Content-Type: application/json charset=UTF-8");

$connect = mysqli_connect('localhost','root','root','22mysql');
if (!$connect) {
    echo json_encode(['code' => 0, 'msg' => '数据库连接失败']);
}
$sql = "select count(*) as value,sex as name from yg GROUP BY sex";
$query = mysqli_query($connect,$sql);
$data = mysqli_fetch_all($query,MYSQLI_ASSOC);
echo json_encode(['code' => 1, 'msg' => '查询成功', 'data' =>[
    'data' => $data
]]);
